# -*- coding: utf-8 -*-
# @Time : 2023/3/14
# @Author : 限量老

from django.urls import path,include
from course import views
from rest_framework.routers import DefaultRouter

router=DefaultRouter()#实例化路由
router.register(prefix='viewsets',viewset=views.CourseViewSet)  #把视图集注册到路由


urlpatterns=[
    #1基本函数视图FBV
    path("fbv/list/", views.course_list, name="fbv-list"),
    path("fbv/detail/<int:pk>/", views.course_detail, name="fbv-detail"),

    #2类视图CBV
    path("cbv/list/", views.CourseList.as_view(), name="cbv-list"),
    path("cbv/detail/<int:pk>/", views.CourseDetail.as_view(), name="cbv-detail"),

    #3通用类视图GCBV
    path("gcbv/list/", views.GCourseList.as_view(), name="gcbv-list"),
    path("gcbv/detail/<int:pk>/", views.GCourseDetail.as_view(), name="gcbv-detail"),

    # #4DRF的视图集viewsets 传统方法的路由
    # path("viewsets/", views.CourseViewSet.as_view({
    #     'get':'list',  #对应drf封装好的方法
    #     'post':'create'
    # }), name="viewsets-list"),
    # path("viewsets/<int:pk>/", views.CourseViewSet.as_view({
    #     'get':'retrieve',  #对应drf封装好的方法
    #     'put':'update',
    #     'patch':'partial_update',
    #     'delete':'destroy'
    # }), name="viewsets-detail"),

    #4DRF的视图集viewsets 简便写法
    path("",include(router.urls))




]







